import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;

public class TickCounter {

	protected final Cipher cipher;
	
	public TickCounter() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException {
		KeyGenerator keyGen = KeyGenerator.getInstance("AES");
		keyGen.init(256);
		SecretKey key = keyGen.generateKey();
		cipher = Cipher.getInstance("AES");
		cipher.init(Cipher.ENCRYPT_MODE, key);
	}
	
	private long counter = 0;
	
	public byte[] cipher(byte[] in) throws IllegalBlockSizeException, BadPaddingException {
		++counter;
		return cipher.doFinal(in);
	}
	
	public long getCount() {
		return counter;
	}
}